package com.sgb.kjwl.view.ui.activity.material.hall;

import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;
import com.scwang.smart.refresh.layout.listener.ScrollBoundaryDecider;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.view.event.special.QuickEntryEvent;
import com.sgb.kjwl.view.ui.quickentry.BackResultContentListener;
import com.sgb.kjwl.view.ui.quickentry.QuickEntryEntity;
import com.sgb.link.utils.PickCateType;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.NewFragmentPickNoticeBinding;
import com.sgb.kjwl.di.home.DaggerHomeFragComponent;
import com.sgb.kjwl.di.home.HomeFragModule;
import com.sgb.kjwl.model.entity.pick.PreNoticeItemEntity;
import com.sgb.link.utils.SizeUtils;
import com.swgk.core.event.EventConstant;
import com.sgb.link.event.MaterialEvent;
import com.sgb.kjwl.view.ui.activity.pick.PickNoticeDetailActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickNoticeSearchActivity;
import com.sgb.kjwl.view.ui.adapter.pick.PickNoticeListAdapter;
import com.sgb.kjwl.view.widget.CommonCategoryFilterPopWindow;
import com.sgb.kjwl.view.widget.PickHallBidingPopWindow;
import com.sgb.kjwl.view.widget.pick.PickChooseLeftDialog2;
import com.sgb.kjwl.view.widget.pick.PickPopWindowView;
import com.sgb.zhaocai.utils.PickUtil;
import com.sgb.zhaocai.utils.PickCopyUtils;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.util.PickSelectEntity;
import com.swgk.core.util.PickSelectTextEntity;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

/**
 * 招标预告
 *
 * @author Administrator
 */
public class PickNoticeFragment extends AppLazyFragment implements PickChooseLeftDialog2.DialogCallBackImpl {

    private NewFragmentPickNoticeBinding binding;
    @Inject
    PickNoticeFragmentModle pickNoticeModel;

    private PickNoticeListAdapter adapter;
    private boolean isMore = false;

    private PickHallBidingPopWindow pickSortPopWindow;
    private CommonCategoryFilterPopWindow categoryFilterPopWindow;
    private PickHallBidingPopWindow applyPopWindow;
    private PickHallBidingPopWindow pickTypePopWindow;
    private PickHallBidingPopWindow pickMoneyPopWindow;
    private PickHallBidingPopWindow pickTabLayoutPopWindow;

    private List<PickSelectEntity> typeDatas = new ArrayList<>();
    private List<PickSelectEntity> sortData = new ArrayList<>();
    private List<PickSelectEntity<List<PickSelectEntity<List<PickSelectEntity>>>>> categoryDatas = new ArrayList<>();
    private List<PickSelectEntity> tabTypeList = new ArrayList<>();
    private PickSelectEntity all;

    //排序类型
    private String sortType = "1";
    private String sortTypeName;
    //省
    private String areacode;
    //地区
    private String citysNos;
    private String goodsType = "";
    private String goodsTypeName;
    //金额
    private String price = "";
    //时间
    private String time = "";
    //招标类型
    private String tenderTypeNos;
    //报名类型 2.9版
    private String tenderApplyNo = "";
    private String tenderApplyName;
    //类型
    private String typeNos;
    private int tabPosition = 0;
    public static final String FROM_WHERE = "FROM_WHERE";

    private boolean isUpDragging = true;

    private AppBarLayout.LayoutParams layoutParams;
    private boolean isAppBarExpended = false;
    private static final String TGA = "NewPickSigningUpListFragment";
    private boolean isParentAppBarCollapsed = false;
    private GridLayoutManager gridLayoutManager;
    private int tabTypePosition;
    private boolean isDialogData = false;
    private String comNo = "";

    private boolean isEnableLoadMore = false; //是否可以上拉加载

    public static PickNoticeFragment newInstance(String fromWhere) {
        PickNoticeFragment fragment = new PickNoticeFragment();
        Bundle bundle = new Bundle();
        bundle.putString(FROM_WHERE, fromWhere);
        fragment.setArguments(bundle);
        return fragment;
    }

    public static PickNoticeFragment newInstance(String fromWhere, String comNo) {
        PickNoticeFragment fragment = new PickNoticeFragment();
        Bundle bundle = new Bundle();
        bundle.putString(FROM_WHERE, fromWhere);
        bundle.putString("comNo", comNo);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerHomeFragComponent
                .builder()
                .appComponent(appComponent)
                .homeFragModule(new HomeFragModule(this))
                .build()
                .inject(this);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }

    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.new_fragment_pick_notice, container, false);
        //商品需求大厅进来
        if ("1".equals(getArguments().get(FROM_WHERE))) {
            binding.includeLayout.setVisibility(View.VISIBLE);
            binding.ivBack.setVisibility(View.GONE);
            binding.liuhaiStatusView.setVisibility(View.GONE);
            binding.linSearch.setVisibility(View.GONE);
            binding.tabLayout.setVisibility(View.GONE);
            binding.lineTabType.setVisibility(View.GONE);
            //商品首页进来
        } else if ("0".equals(getArguments().get(FROM_WHERE))) {
            binding.includeLayout.setVisibility(View.GONE);
            binding.ivBack.setVisibility(View.GONE);
            binding.liuhaiStatusView.setVisibility(View.GONE);
            binding.tabLayout.setVisibility(View.GONE);
            binding.imgBackTop.setVisibility(View.GONE);
            binding.lineTabType.setVisibility(View.GONE);
        } else {
            //招采模块   招标预告
            if ("2".equals(getArguments().get(FROM_WHERE))) {
                binding.imgBackTop.setVisibility(View.GONE);
                binding.includeLayout.setVisibility(View.VISIBLE);
                binding.ivBack.setVisibility(View.VISIBLE);
                binding.liuhaiStatusView.setVisibility(View.VISIBLE);
                binding.tabLayout.setVisibility(View.VISIBLE);
                binding.lineTabType.setVisibility(View.GONE);
            } else if ("3".equals(getArguments().get(FROM_WHERE))) {
                //招标大厅-招标预告    招标公告-招标预告
                binding.includeLayout.setVisibility(View.GONE);
                binding.ivBack.setVisibility(View.VISIBLE);
                binding.liuhaiStatusView.setVisibility(View.VISIBLE);
                binding.tabLayout.setVisibility(View.VISIBLE);
                binding.lineTabType.setVisibility(View.GONE);
            } else if ("4".equals(getArguments().get(FROM_WHERE))) {
                //招采 - 企业网站-需求公告-招采需求
                binding.llContainer.setVisibility(View.GONE);
                binding.includeLayout.setVisibility(View.GONE);
                binding.noticeList.setVisibility(View.VISIBLE);
            }
        }
        comNo = getArguments().getString(comNo);
        return binding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    private void init() {
        initChooseDialog();
        categoryFilterPopWindow = new CommonCategoryFilterPopWindow(getActivity(), false);
        categoryFilterPopWindow.setBgView(binding.grayLayout);
        categoryFilterPopWindow.setResultListener(new CommonCategoryFilterPopWindow.Listener() {
            @Override
            public void setResultListener(String text, String result, String typeNo) {

            }

            @Override
            public void setResetResultListener() {
                addEntity(PickCateType.TYPE_CATEGORY_2, new ArrayList<>());
            }
        });
        categoryFilterPopWindow.setCategoryCallBack(new CommonCategoryFilterPopWindow.CategoryCallBack() {
            @Override
            public void resultPosition(String posName1, String posName2, String posName3, int pos1, int pos2, int pos3) {
                clearOtherDataInfo(PickCateType.TYPE_CATEGORY_0);
                pos1 = tabTypePosition;
                mFilters.put(PickCateType.TYPE_CATEGORY_0, pos1);
                if (pos1 > 0) {
                    if (pos2 > 0) {
                        List<PickSelectEntity> list2 = new ArrayList<>();
                        List<PickSelectEntity<List<PickSelectEntity>>> cate1 = categoryDatas.get(pos1).getChildren();
                        if (cate1 != null && cate1.size() > 0) {
                            list2.addAll(cate1);
                        }
                        refreshDataInfo(PickCateType.TYPE_CATEGORY_1, "", list2);
                        updateChooseStatus(PickCateType.TYPE_CATEGORY_1, pos2);
                        if (pos3 > 0) {
                            List<PickSelectEntity> list3 = new ArrayList<>();
                            List<PickSelectEntity> cate2 = categoryDatas.get(pos1).getChildren().get(pos2).getChildren();
                            if (cate2 != null && cate2.size() > 0) {
                                list3.addAll(cate2);
                            }
                            refreshDataInfo(PickCateType.TYPE_CATEGORY_2, "", list3);
                            updateChooseStatus(PickCateType.TYPE_CATEGORY_2, pos3);
                        }
                    } else {
                        //重置
                        updateChooseStatus(PickCateType.TYPE_CATEGORY_0, 0);
                    }
                }
                pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
            }
        });
        categoryFilterPopWindow.setOnDisMissClick(new BasePopWindow.OnDisMiss() {
            @Override
            public void disMiss() {
                int pos1 = getItemPos(PickCateType.TYPE_CATEGORY_0);
                updateChooseTextStatus(binding.tvCategory, pos1 > 0 ? 1 : 0, goodsTypeName);
            }
        });
        // 招标方式
//        pickTypePopWindow = new PickHallBidingPopWindow(getActivity());
//        pickTypePopWindow.setBgView(binding.grayLayout);
//        pickTypePopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
//            @Override
//            public void result(Object key1, Object key2, Object key3) {
//                updateChooseStatus(PickCateType.TYPE_BIDDING, (Integer) key3);
//                pickNoticeModel.getBiddingListData("",typeNos,goodsType,tenderTypeNos,tenderApplyNo,time,price,areacode,citysNos,sortType);
//            }
//        });
//        pickTypePopWindow.setOnDisMissClick(new BasePopWindow.OnDisMiss() {
//            @Override
//            public void disMiss() {
//                int value = getItemPos(PickCateType.TYPE_BIDDING);
//                updateChooseTextStatus(binding.tvType, value > 0 ? 1 : 0, null);
//            }
//        });

        // 报名方式   现招标方式
        applyPopWindow = new PickHallBidingPopWindow(getActivity());
        applyPopWindow.setBgView(binding.grayLayout);
        applyPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                updateChooseStatus(PickCateType.TYPE_SIGN, (Integer) key3);
                pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
            }
        });
        applyPopWindow.setOnDisMissClick(new BasePopWindow.OnDisMiss() {
            @Override
            public void disMiss() {
                int value = getItemPos(PickCateType.TYPE_SIGN);
                updateChooseTextStatus(binding.tvApply, value > 0 ? 1 : 0, tenderApplyName);
            }
        });
        //排序方式
        pickSortPopWindow = new PickHallBidingPopWindow(getActivity());
        pickSortPopWindow.setBgView(binding.grayLayout);
        pickSortPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                sortTypeName = ((PickSelectEntity) key1).getProjectscale();
                sortType = ((PickSelectEntity) key1).getNo();
                updateChooseTextStatus(binding.tvSort, (Integer) key3, sortTypeName);
                pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
            }
        });
        pickSortPopWindow.setOnDisMissClick(new BasePopWindow.OnDisMiss() {
            @Override
            public void disMiss() {
                updateChooseTextStatus(binding.tvSort, Integer.valueOf(sortType) == 1 ? 0 : 1, sortTypeName);
            }
        });
        // 金额
        pickMoneyPopWindow = new PickHallBidingPopWindow(getActivity());
        pickMoneyPopWindow.setBgView(binding.grayLayout);
        pickMoneyPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                updateChooseStatus(PickCateType.TYPE_MONEY, (Integer) key3);
                pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
            }
        });
        pickMoneyPopWindow.setOnDisMissClick(new BasePopWindow.OnDisMiss() {
            @Override
            public void disMiss() {
                int value = getItemPos(PickCateType.TYPE_MONEY);
                updateChooseTextStatus(binding.tvMoney, value > 0 ? 1 : 0, null);
            }
        });
        pickMoneyPopWindow.setDefItem();

        binding.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                tabPosition = tab.getPosition();
                typeNos = typeDatas.get(tabPosition).getNo();
                isMore = false;
                if (tabPosition == 0 || tabPosition == (typeDatas.size() - 1)) {
                    binding.tvCategory.setVisibility(View.GONE);
                    if (mData != null && mData.size() > 0 && mData.get(0) != null) {
                        if (mData.get(0).getTypeName().contains("类别")) {
                            mData.remove(0);
                        }
                    }
                    pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
                } else {
                    binding.tvCategory.setVisibility(View.VISIBLE);
                    binding.tvMoney.setVisibility(View.GONE);
                    resetCategoryFilterPopWindow();
                }
                clearOtherDataInfo(PickCateType.TYPE_CATEGORY_0);
                clearOtherDataInfo(PickCateType.TYPE_PROVINCE);
//                loadData(mData, mFilters);
                if (adapter != null) {
                    adapter.setTabPosition(tabPosition);
                }
                if (tabPosition == 0 || tabPosition == (typeDatas.size() - 1)) {
                    binding.lineTabType.setVisibility(View.GONE);
                } else {
                    tabTypeList.clear();
                    binding.tabLayoutType.setTabRippleColor(ColorStateList.valueOf(getContext().getResources().getColor(R.color.translucent)));
                    binding.tabLayoutType.removeAllTabs();
                    binding.lineTabType.setVisibility(View.VISIBLE);
                    binding.tvCategory.setVisibility(View.GONE);
                    mFilters.put(PickCateType.TYPE_CATEGORY_0, 0);
                    mFilters.put(PickCateType.TYPE_CATEGORY_1, 0);
                    mFilters.put(PickCateType.TYPE_CATEGORY_2, 0);
                }

                if (tab != null && tab.getCustomView() != null) {
                    TextView tabSelect = tab.getCustomView().findViewById(R.id.tv_tab_item);
                    ImageView imageView = tab.getCustomView().findViewById(R.id.image_tab_item);
                    PickCopyUtils.setImageResources(tabPosition, imageView, true, getContext());
                    tabSelect.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                    tabSelect.setTextColor(getResources().getColor(R.color.APPTabColor));
                    tabSelect.invalidate();
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                if (tab != null && tab.getCustomView() != null) {
                    TextView tabSelect = tab.getCustomView().findViewById(R.id.tv_tab_item);
                    ImageView imageView = tab.getCustomView().findViewById(R.id.image_tab_item);
                    PickCopyUtils.setImageResources(tabPosition, imageView, false, getContext());
                    tabSelect.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
                    tabSelect.setTextColor(getResources().getColor(R.color.color_tab_one));
                    tabSelect.invalidate();
                }
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

        binding.tabLayoutType.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                isMore = false;
                tabTypePosition = tab.getPosition();
                if (tabTypePosition == 0) {
                    binding.tvCategory.setVisibility(View.GONE);
                } else {
                    List<PickSelectEntity<List<PickSelectEntity>>> pickSelectEntities = categoryDatas.get(tabTypePosition).getChildren();
                    if (pickSelectEntities == null || pickSelectEntities.size() == 0) {
                        binding.tvCategory.setVisibility(View.GONE);
                    } else {
                        binding.tvCategory.setVisibility(View.VISIBLE);
                        if (!isDialogData) {
                            updateChooseStatus(PickCateType.TYPE_CATEGORY_0, 0);
                            mFilters.put(PickCateType.TYPE_CATEGORY_1, 0);
                            mFilters.put(PickCateType.TYPE_CATEGORY_2, 0);
                            List<PickSelectEntity> list2 = new ArrayList<>();
                            List<PickSelectEntity<List<PickSelectEntity>>> cate1 = categoryDatas.get(tabTypePosition).getChildren();
                            if (cate1 != null && cate1.size() > 0) {
                                list2.addAll(cate1);
                            }
                            refreshDataInfo(PickCateType.TYPE_CATEGORY_1, "", list2);
                        }
                    }
                }
                pickTabLayoutPopWindow.setDefItem(tabTypePosition);
                goodsType = tabTypeList.get(tabTypePosition).getNo();
                isDialogData = false;
                pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);

                if (tab != null && tab.getCustomView() != null) {
                    TextView tabSelect = tab.getCustomView().findViewById(R.id.tv_tab_item);
                    tabSelect.setBackgroundResource(R.drawable.search_new_blue_bg_10);
                    tabSelect.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                    tabSelect.setTextColor(getResources().getColor(R.color.APPTabColor));
                    tabSelect.invalidate();
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                if (tab != null && tab.getCustomView() != null) {
                    TextView tabSelect = tab.getCustomView().findViewById(R.id.tv_tab_item);
                    tabSelect.setBackgroundResource(R.drawable.search_bg);
                    tabSelect.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
                    tabSelect.setTextColor(getResources().getColor(R.color.color_tab_one));
                    tabSelect.invalidate();
                }
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });


        //类别二级
        pickTabLayoutPopWindow = new PickHallBidingPopWindow(getActivity());
        pickTabLayoutPopWindow.setBgView(binding.grayLayout);
        pickTabLayoutPopWindow.setOnResultClick((key1, key2, key3) -> {
            binding.tabLayoutType.getTabAt((int) key3).select();
            pickTabLayoutPopWindow.setDefItem((int) key3);
            goodsType = ((PickSelectEntity) key1).getNo();
            pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
        });
        pickTabLayoutPopWindow.setOnDisMissClick(() -> {
            binding.surveyView.setImageResource(R.drawable.btn_down);
        });

        all = new PickSelectEntity();
        all.setNo("");
        all.setProjectscale("全部");

    }


    private void initViewData() {
        binding.etView.setOnClickListener(this);
        binding.imgBackTop.setOnClickListener(this);
        binding.tvApply.setOnClickListener(this);
        binding.tvSort.setOnClickListener(this);
        binding.ivBack.setOnClickListener(this);
        binding.ivChoose.setOnClickListener(this);
        binding.tvCategory.setOnClickListener(this);
        binding.tvMoney.setOnClickListener(this);
        binding.surveyView.setOnClickListener(this);
        binding.tvSearch.setOnClickListener(this);
        binding.rightView.setOnClickListener(this);
        binding.ivQuickEntry.setOnClickListener(this);
        gridLayoutManager = new GridLayoutManager(getActivity(), 1);
        binding.noticeList.setLayoutManager(gridLayoutManager);
        adapter = new PickNoticeListAdapter(getActivity(), null);
        DividerItemDecoration divider = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL);
        divider.setDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.shape_list_divide1));
        binding.noticeList.addItemDecoration(divider);
        binding.noticeList.setAdapter(adapter);
        binding.swipeRefresh.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                isMore = true;
                pickNoticeModel.prepage.set(pickNoticeModel.prepage.get() + 1);
                pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
//                binding.swipeRefresh.finishLoadMore(300);
            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                isMore = false;
                //招标中
                pickNoticeModel.prepage.set(1);
                pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);

                binding.swipeRefresh.finishRefresh(300);
            }
        });
        //解决 在实现 上拉加载更多 和 下拉刷新 时  遇到item不在顶端就执行了刷新的方法和数据item没有填满屏幕也执行了加载更多
        binding.swipeRefresh.setScrollBoundaryDecider(new ScrollBoundaryDecider() {
            @Override
            public boolean canRefresh(View content) {
                if (binding.scrollview == null) return false;
                if (binding.scrollview.computeVerticalScrollOffset() == 0)
                    return true;
                return false;
            }

            @Override
            public boolean canLoadMore(View content) {
                if (binding.scrollview == null) return false;
                //获取recyclerView的高度
                binding.scrollview.getHeight();
                //整个View控件的高度
                int scrollRange = binding.scrollview.computeVerticalScrollRange();
                //当前屏幕之前滑过的距离
                int scrollOffset = binding.scrollview.computeVerticalScrollOffset();
                //当前屏幕显示的区域高度
                int scrollExtent = binding.scrollview.computeVerticalScrollExtent();
                int height = binding.scrollview.getHeight();
                if (height > scrollRange) {
                    return false;
                }
                if (isEnableLoadMore && scrollRange <= scrollOffset + scrollExtent) {
                    return true;
                }
                return false;
            }
        });

        adapter.setOnItemClick(new AdapterOnItemClick<PreNoticeItemEntity>() {
            @Override
            public void onItemClick(PreNoticeItemEntity goodsInfoEntity3, int position) {
                PickNoticeDetailActivity.start(getActivity(), goodsInfoEntity3.getTenderNo() + "");
            }
        });

        adapter.onIChildClick(new PickNoticeListAdapter.IChildClick() {
            @Override
            public void onClick(PreNoticeItemEntity preNoticeItemEntity) {
                PickNoticeDetailActivity.start(getActivity(), preNoticeItemEntity.getTenderNo() + "");
            }
        });

        if (getArguments() != null && "0".equals(getArguments().get(FROM_WHERE))) {
            binding.noticeList.setOverScrollMode(View.OVER_SCROLL_NEVER);
//            binding.noticeList.setPullRefreshEnabled(false);
            //initStickView();
        }

        int screenHeight = SizeUtils.getScreenHeight(getActivity());
        binding.noticeList.setOnScrollChangeListener(new View.OnScrollChangeListener() {
            @Override
            public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                RecyclerView.LayoutManager layoutManager = binding.noticeList.getLayoutManager();
                View view = layoutManager.findViewByPosition(0);
                if (view != null){
                    int height = view.getMeasuredHeight();
                    int headHeight = screenHeight - binding.llContainer.getHeight();
                    int gonePosition = 10 - (headHeight / view.getHeight());
                    binding.imgBackTop.setVisibility((height * gonePosition) > scrollY ? View.GONE : View.VISIBLE);
                }
            }
        });

    }

    @Override
    protected void onLazyLoad() {
        initData();
    }

    @Override
    protected void initView() {
        super.initView();
        initViewData();
        init();
    }

    private void initData() {
        //招标方式
//        String[] stringType = new String[]{"全部", "公开招标&1", "邀请招标&2"};
//        setPickTypeDatas(stringType);

        //报名开始时间
        String[] stringTime = new String[]{"全部", "今天&1", "3天内&3", "5天内&5", "10天内&10", "30天内&30", "30天以上&31"};
        setTimeDatas(stringTime);

        pickNoticeModel.getProvinceData();
        pickNoticeModel.getFilterTypeData();
        pickNoticeModel.getSortTypeData();
        pickNoticeModel.getPriceData();
        pickNoticeModel.getTenderNewTypeList();
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                getActivity().finish();
                break;
            case R.id.et_view:
            case R.id.tv_search:
                PickNoticeSearchActivity.start(getActivity());
                break;
            case R.id.img_back_top:
                binding.imgBackTop.setVisibility(View.GONE);
                binding.scrollview.smoothScrollTo(0, 0);
                binding.scrollview.scrollTo(0, 0);
                break;
            case R.id.tv_category:
                if (null != categoryDatas && categoryDatas.size() > 0) {
                    if (TextUtils.isEmpty(goodsTypeName)) {
                        goodsTypeName = "类别";
                    }
                    updateChooseTextStatus(binding.tvCategory, TextUtils.isEmpty(goodsType) ? -1 : -2, goodsTypeName);
                    if ("0".equals(getArguments().get(FROM_WHERE))) {
                        EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
                        new Handler().postDelayed(() -> categoryFilterPopWindow.showPopwindow(binding.tvCategory, 0, 0), 300);
                    } else {
                        categoryFilterPopWindow.showPopWindow1(binding.tvCategory);
                    }
                    if (!TextUtils.isEmpty(typeNos)) {
                        categoryFilterPopWindow.setData2(categoryDatas.get(tabTypePosition).getChildren(), Integer.valueOf(typeNos), typeDatas.get(tabPosition).getProjectscale());
                    }
                    int pos1 = getItemPos(PickCateType.TYPE_CATEGORY_0);
                    int pos2 = getItemPos(PickCateType.TYPE_CATEGORY_1);
                    int pos3 = getItemPos(PickCateType.TYPE_CATEGORY_2);
                    categoryFilterPopWindow.setCateData(pos1, pos2, pos3);
                }
                break;
//            case R.id.tv_type:  //招标方式
//                List<PickSelectEntity> tenderTypeDatas = getItemData(PickCateType.TYPE_BIDDING);
//                if (tenderTypeDatas != null && tenderTypeDatas.size() > 0) {
//                    updateChooseTextStatus(binding.tvType, TextUtils.isEmpty(tenderTypeNos) ? -1 : -2, null);
//                    pickTypePopWindow.showPopwindow(binding.tvType, 0, 0);
//                    int value = getItemPos(PickCateType.TYPE_BIDDING);
//                    pickTypePopWindow.updateData(value, getItemData(PickCateType.TYPE_BIDDING));
//                }
//                break;
            case R.id.tv_apply: //报名方式
                List<PickSelectEntity> applyDatas = getItemData(PickCateType.TYPE_SIGN);
                if (null != applyDatas && applyDatas.size() > 0) {
                    if (TextUtils.isEmpty(tenderApplyName)) {
                        tenderApplyName = "招标方式";
                    }
                    updateChooseTextStatus(binding.tvApply, TextUtils.isEmpty(tenderApplyNo) ? -1 : -2, tenderApplyName);
                    if ("0".equals(getArguments().get(FROM_WHERE))) {
                        EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
                        new Handler().postDelayed(() -> applyPopWindow.showPopwindow(binding.tvApply, 0, 0), 300);
                    } else {
                        applyPopWindow.showPopwindow0(binding.tvApply);
                    }
                    int value = getItemPos(PickCateType.TYPE_SIGN);
                    applyPopWindow.updateData(value, getItemData(PickCateType.TYPE_SIGN));
                }
                break;
            case R.id.tv_money:
                updateChooseTextStatus(binding.tvMoney, TextUtils.isEmpty(price) ? -1 : -2, null);
                pickMoneyPopWindow.showPopwindow0(binding.tvMoney);
                int value = getItemPos(PickCateType.TYPE_MONEY);
                pickMoneyPopWindow.setData(getItemData(PickCateType.TYPE_MONEY), value);
                break;
            case R.id.iv_choose:
                if (!TextUtils.isEmpty(typeNos)) {
                    mFilters.put(PickCateType.TYPE_CATEGORY_0, tabTypePosition);
                    mLeftDialog2.initCategory(Integer.parseInt(typeNos), false, false);
                    mLeftDialog2.initData(mData, mFilters);
                    mLeftDialog2.showDialog();
                }
                break;
            case R.id.tv_sort:
                if (TextUtils.isEmpty(sortTypeName)) {
                    sortTypeName = "综合排序";
                    pickSortPopWindow.setDefItem();
                }
                updateChooseTextStatus(binding.tvSort, Integer.valueOf(sortType) == 1 ? -1 : -2, sortTypeName);
                if ("0".equals(getArguments().get(FROM_WHERE))) {
                    EventBus.getDefault().post(new MaterialEvent().setMessageTag(EventConstant.EVENT_LOGISTICS_WINDOW_TOP));
                    new Handler().postDelayed(() -> pickSortPopWindow.showPopwindow(binding.tvSort, 0, 0), 300);
                } else {
                    pickSortPopWindow.showPopwindow0(binding.tvSort);
                }
                pickSortPopWindow.setData(sortData, false);
                break;
            case R.id.survey_view:
                binding.surveyView.setImageResource(R.drawable.btn_shop_up);
                pickTabLayoutPopWindow.showPopwindow(binding.surveyView);
                pickTabLayoutPopWindow.setData(tabTypeList, binding.tabLayoutType.getSelectedTabPosition());
                break;
            case R.id.right_view:
                PickUtil.showBottomZhaoCaiDialog(getContext());
                break;
            case R.id.iv_quick_entry:
                EventBus.getDefault().postSticky(new QuickEntryEvent(binding.ivQuickEntry, new BackResultContentListener() {
                    @Override
                    public boolean backResult(QuickEntryEntity entity) {
                        switch (entity.getId()) {
                            case "2-5": //招标预告
                                return true;
                            default:
                                getActivity().finish();
                                return false;
                        }
                    }
                }));
                break;
        }
    }

    public void setSortDatas(List<PickSelectEntity> datas) {
        sortData.clear();
        sortData.addAll(datas);
    }

    private void resetCategoryFilterPopWindow() {
        clearOtherDataInfo(PickCateType.TYPE_CATEGORY_0);
        getCategoryAllList();
    }

    private void getCategoryAllList() {
        pickNoticeModel.getTenderGoodsCategoryAllList(typeNos);
    }

    private PickChooseLeftDialog2 mLeftDialog2;
    // 数据集
    private SparseArray<PickSelectTextEntity> mData = new SparseArray<>();
    private SparseIntArray mFilters = new SparseIntArray();
    private SparseArray<String> nameArray = new SparseArray<>();

    private void initChooseDialog() {
        nameArray.put(PickCateType.TYPE_CATEGORY_0, "类别");
        nameArray.put(PickCateType.TYPE_CATEGORY_1, "类别1");
        nameArray.put(PickCateType.TYPE_CATEGORY_2, "类别2");
//        nameArray.put(PickCateType.TYPE_BIDDING, "招标方式");
        nameArray.put(PickCateType.TYPE_SIGN, "招标方式");
        nameArray.put(PickCateType.TYPE_START_TIME, "报名开始时间");
        nameArray.put(PickCateType.TYPE_MONEY, "概算金额");
        nameArray.put(PickCateType.TYPE_PROVINCE, "省份");
        nameArray.put(PickCateType.TYPE_CITY, "市区");
        mLeftDialog2 = new PickChooseLeftDialog2(getActivity(), nameArray);
        mLeftDialog2.setCallBack(this);
    }

    @Override
    public void loadCategory(PickSelectTextEntity entity, int itemPos) {
        List<PickSelectEntity> children = new ArrayList<>();
        if (itemPos > 0) {
            switch (entity.getSort()) {
                case PickCateType.TYPE_CATEGORY_0:
                    if (categoryDatas == null || categoryDatas.size() == 0) {
                        return;
                    }
                    List<PickSelectEntity<List<PickSelectEntity>>> cate1 = categoryDatas.get(itemPos).getChildren();
                    if (cate1 != null && cate1.size() > 0) {
                        children.addAll(cate1);
                    }
                    mLeftDialog2.clearOtherDataInfo(entity.getSort());
                    mLeftDialog2.addEntity(PickCateType.TYPE_CATEGORY_1, children);
                    mLeftDialog2.showDialog();
                    break;
                case PickCateType.TYPE_CATEGORY_1:
                    if (categoryDatas == null || categoryDatas.size() == 0) {
                        return;
                    }
                    int firPos = mLeftDialog2.getItemPos(0);
                    List<PickSelectEntity> cate2 = categoryDatas.get(firPos).getChildren().get(itemPos).getChildren();
                    if (cate2 != null && cate2.size() > 0) {
                        children.addAll(cate2);
                    }
                    mLeftDialog2.clearOtherDataInfo(entity.getSort());
                    mLeftDialog2.addEntity(PickCateType.TYPE_CATEGORY_2, children);
                    mLeftDialog2.showDialog();
                    break;
                case PickCateType.TYPE_PROVINCE:
                    pickNoticeModel.getCityData(entity.getItemNo(itemPos), true);
                    break;
            }
        } else {
            if (entity.getSort() == PickCateType.TYPE_CATEGORY_0 || entity.getSort() == PickCateType.TYPE_CATEGORY_1 || entity.getSort() == PickCateType.TYPE_PROVINCE) {
                mLeftDialog2.clearOtherDataInfo(entity.getSort());
                mLeftDialog2.showDialog();
            }
        }

    }

    @Override
    public void loadData(SparseArray<PickSelectTextEntity> data, SparseIntArray map) {
        mData = PickCopyUtils.deepCopy(data);
        mFilters = map.clone();
        if (mFilters.size() > 0 && mFilters.get(0) > 0) {
            isDialogData = true;
            binding.tabLayoutType.getTabAt(mFilters.get(0)).select();
        }
        for (int i = 0; i < mData.size(); i++) {
            int key = mData.keyAt(i);
            PickSelectTextEntity entity = mData.get(key);
            updateChooseStatus(entity.getSort(), mFilters.get(entity.getSort()));
        }
        pickNoticeModel.getBiddingListData("", typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
    }

    @Override
    public void reset() {
        mFilters.clear();
        clearOtherDataInfo(PickCateType.TYPE_CATEGORY_0);
        clearOtherDataInfo(PickCateType.TYPE_PROVINCE);
        loadData(mData, mFilters);
        mLeftDialog2.initData(mData, mFilters);
        mLeftDialog2.showDialog();
        if (binding.tabLayoutType.getTabAt(0) != null) {
            binding.tabLayoutType.getTabAt(0).select();
        }
    }

    @Override
    public void onCancel() {
        mLeftDialog2.initData(mData, mFilters);
    }

    /**
     * 添加数据到中数据聚合
     */
    private void refreshDataInfo(int sort, String name, List<PickSelectEntity> children) {
        clearOtherDataInfo(sort);
        addEntity(sort, children, name);
    }

    /**
     * 清理关联项为空
     */
    private void clearOtherDataInfo(int sort) {
        switch (sort) {
            case PickCateType.TYPE_CATEGORY_0:
                addEntity(PickCateType.TYPE_CATEGORY_1, new ArrayList<>());
                addEntity(PickCateType.TYPE_CATEGORY_2, new ArrayList<>());
                break;
            case PickCateType.TYPE_CATEGORY_1:
                addEntity(PickCateType.TYPE_CATEGORY_2, new ArrayList<>());
                break;
            case PickCateType.TYPE_PROVINCE:
                addEntity(PickCateType.TYPE_CITY, new ArrayList<>());
                break;
        }
    }

    public void addEntity(int index, List<PickSelectEntity> list) {
        if (mData.get(index) != null) {
            if (list == null || list.size() == 0) {
                mData.get(index).setPickSelectEntityList(new ArrayList<>());
            } else {
                mData.get(index).setPickSelectEntityList(list);
            }
        } else {
            mData.put(index, new PickSelectTextEntity(index, nameArray.get(index), list));
        }
        mFilters.put(index, 0);
    }

    public void addEntity(int index, List<PickSelectEntity> list, String name) {
        if (mData.get(index) != null) {
            if (list == null || list.size() == 0) {
                mData.get(index).setPickSelectEntityList(new ArrayList<>());
            } else {
                mData.get(index).setPickSelectEntityList(list);
            }
            mData.get(index).setTypeName(name);
        } else {
            mData.put(index, new PickSelectTextEntity(index, name, list));
        }
        mFilters.put(index, 0);
    }

    /**
     * 获取当前缓存位置下标
     *
     * @param pos index
     */
    public int getItemPos(int pos) {
        return mFilters.get(pos);
    }

    public List<PickSelectEntity> getItemData(int index) {
        if (mData.get(index) != null) {
            return mData.get(index).getPickSelectEntityList();
        }
        return new ArrayList<>();
    }

    /**
     * 筛选赋值
     */
    private void updateChooseStatus(int key, int value) {
        mFilters.put(key, value);
        String no = mData.get(key).getItemNo(value);
        String name = mData.get(key).getItemName(value);
        switch (key) {
            case PickCateType.TYPE_CATEGORY_0:  //类别
            case PickCateType.TYPE_CATEGORY_1:
                if (TextUtils.isEmpty(no)) {
                    goodsTypeName = "类别";
                } else {
                    goodsType = no;
                    goodsTypeName = name;
                }
                updateChooseTextStatus(binding.tvCategory, value, goodsTypeName);
                break;
            case PickCateType.TYPE_CATEGORY_2:
                if (!TextUtils.isEmpty(no)) {
                    goodsType = no;
                    goodsTypeName = name;
                    if (value > 0) {
                        updateChooseTextStatus(binding.tvCategory, value, goodsTypeName);
                    }
                }
                break;
//            case PickCateType.TYPE_BIDDING: // 招标方式
//                tenderTypeNos = no;
//                updateChooseTextStatus(binding.tvType, value, name);
//                break;
            case PickCateType.TYPE_SIGN: // 报名方式
                tenderApplyNo = no;
                tenderApplyName = name;
                updateChooseTextStatus(binding.tvApply, value, name);
                break;
            case PickCateType.TYPE_MONEY: // 概算金额
                price = no;
                updateChooseTextStatus(binding.tvMoney, value, name);
                break;
            case PickCateType.TYPE_START_TIME: // 报名开始时间
                time = no;
                break;
            case PickCateType.TYPE_PROVINCE: // 省
                areacode = no;
                break;
            case PickCateType.TYPE_CITY: // 城市
                citysNos = no;
                break;
        }
    }

    /**
     * 更新选项颜色
     */
    private void updateChooseTextStatus(PickPopWindowView pickPopWindowView, int value, String name) {
        if (!TextUtils.isEmpty(name)) {
            if (name.length() > 4) {
                name = name.substring(0, 4) + "...";
            }
        }
        if (value == -1 || value == -2) {
            binding.popLine.setVisibility(View.VISIBLE);
            pickPopWindowView.setChooseData(R.drawable.member_pop_blue_bg2, R.mipmap.ic_up_arrow_n, R.color.color_333333, true, name);
        } else if (value == 0) {
            binding.popLine.setVisibility(View.GONE);
            pickPopWindowView.setChooseData(R.drawable.search_bg, R.mipmap.ic_down_arrow_n, R.color.color_333333, false, name);
        } else {
            binding.popLine.setVisibility(View.GONE);
            pickPopWindowView.setChooseData(R.drawable.search_new_blue_bg_10, R.mipmap.icon_down_red, R.color.color_main, false, name);
        }
    }

    private void setTextViewBg(TextView textView, int bg, int img, int textColor) {
        if (getActivity() != null && !getActivity().isFinishing() && !getActivity().isDestroyed()) {
            if (isAdded()) {
                textView.setBackground(getResources().getDrawable(bg));
                Drawable drawable_n = getResources().getDrawable(img);
                drawable_n.setBounds(0, 0, drawable_n.getMinimumWidth(), drawable_n.getMinimumHeight());  //此为必须写的
                textView.setCompoundDrawables(null, null, drawable_n, null);
                textView.setTextColor(getResources().getColor(textColor));
            }
        }
    }

    /**
     * 分类
     */
    public void setTenderGoodsCategoryAllList(List<PickSelectEntity<List<PickSelectEntity<List<PickSelectEntity>>>>> datas) {
        categoryDatas.clear();
        categoryDatas.addAll(datas);
        if (categoryDatas.size() != 0) {
            categoryDatas.get(0).setCheck(true);
            List<PickSelectEntity> list = new ArrayList<>();
            list.addAll(categoryDatas);
            refreshDataInfo(PickCateType.TYPE_CATEGORY_0, "类别", list);

            for (int i = 0; i < categoryDatas.size(); i++) {
                PickSelectEntity pickSelectEntity = new PickSelectEntity(categoryDatas.get(i).getNo(), categoryDatas.get(i).getProjectscale());
                tabTypeList.add(pickSelectEntity);
                binding.tabLayoutType.addTab(binding.tabLayoutType.newTab().setText(pickSelectEntity.getProjectscale()));

                binding.tabLayoutType.getTabAt(i).setCustomView(R.layout.tab_item_textview_pick);

                TextView tv = binding.tabLayoutType.getTabAt(i).getCustomView().findViewById(R.id.tv_tab_item);
                if (pickSelectEntity.getProjectscale().length() > 4) {
                    tv.setText(pickSelectEntity.getProjectscale().substring(0, 4) + "...");
                } else {
                    if (i == 0) {
                        tv.setBackgroundResource(R.drawable.search_new_blue_bg_10);
                        tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                        tv.setTextColor(getResources().getColor(R.color.APPTabColor));
                    }
                    tv.setText(pickSelectEntity.getProjectscale());
                }
            }
        }
    }

    /**
     * 招标方式
     */
    private void setPickTypeDatas(String[] strings) {
        List<PickSelectEntity> tenderTypeDatas = new ArrayList<>();
        for (String s : strings) {
            PickSelectEntity pickSelectEntity = new PickSelectEntity();
            if (s.contains("&")) {
                String[] splitText = s.split("&");
                pickSelectEntity.setNo(splitText[1]);
                pickSelectEntity.setProjectscale(splitText[0]);
            } else {
                pickSelectEntity.setNo("");
                pickSelectEntity.setProjectscale(s);
            }
            tenderTypeDatas.add(pickSelectEntity);
        }
        refreshDataInfo(PickCateType.TYPE_BIDDING, "招标方式", tenderTypeDatas);
    }

    public void setTypeDatas(List<PickSelectEntity> datas) {
        if (datas == null) return;
        typeDatas.clear();
        typeDatas.addAll(datas);
        for (int i = 0; i < typeDatas.size(); i++) {
            binding.tabLayout.addTab(binding.tabLayout.newTab());
            binding.tabLayout.getTabAt(i).setCustomView(R.layout.tab_item_text_image_view);

            View view = binding.tabLayout.getTabAt(i).getCustomView();
            TextView tv = view.findViewById(R.id.tv_tab_item);
            ImageView imageView = view.findViewById(R.id.image_tab_item);
            if (i == 0) {
                tv.setTextColor(getResources().getColor(R.color.APPTabColor));
                tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                PickCopyUtils.setImageResources(0, imageView, true, getContext());
            } else {
                PickCopyUtils.setImageResources(i, imageView, false, getContext());
            }
            tv.setText(typeDatas.get(i).getProjectscale());

        }

        if ("1".equals(getArguments().getString(FROM_WHERE)) || "0".equals(getArguments().getString(FROM_WHERE))) {
            binding.tabLayout.getTabAt(1).select(); //默认选中某项放在加载viewpager之后
        } else {
            binding.tabLayout.getTabAt(0).select();
        }

    }

    public void setTenderTypeDatas(List<PickSelectEntity> datas) {
        refreshDataInfo(PickCateType.TYPE_SIGN, "报名方式", datas);
    }

    /**
     * 报名开始时间
     */
    private void setTimeDatas(String[] strings) {
        List<PickSelectEntity> datas = new ArrayList<>();
        for (String s : strings) {
            PickSelectEntity pickSelectEntity = new PickSelectEntity();
            if (s.contains("&")) {
                String[] splitText = s.split("&");
                pickSelectEntity.setNo(splitText[1]);
                pickSelectEntity.setProjectscale(splitText[0]);
            } else {
                pickSelectEntity.setNo("");
                pickSelectEntity.setProjectscale(s);
            }
            datas.add(pickSelectEntity);
        }
        refreshDataInfo(PickCateType.TYPE_START_TIME, "报名开始时间", datas);
    }

    public void setPriceDatas(List<PickSelectEntity> datas) {
        refreshDataInfo(PickCateType.TYPE_MONEY, "概算金额", datas);
    }

    public void setProvinceDatas(List<PickSelectEntity> datas) {
        refreshDataInfo(PickCateType.TYPE_PROVINCE, "省份", datas);
    }

    public void setCityDatas(List<PickSelectEntity> datas, boolean isShowDialog) {
        datas.add(0, all);
        if (isShowDialog) {
            mLeftDialog2.addEntity(PickCateType.TYPE_CITY, datas);
            mLeftDialog2.showDialog();
        }
    }

    public void getBidedData(List<PreNoticeItemEntity> list) {
        binding.swipeRefresh.finishLoadMore(true);
        if (!isMore) {
            binding.imgBackTop.setVisibility(View.GONE);
            binding.scrollview.smoothScrollTo(0, 0);
            binding.scrollview.scrollTo(0, 0);
        }
        if (list != null){
            isEnableLoadMore = list.size() >= 10;
        }
        if (isMore) {
            if (list != null && !list.isEmpty()) {
                adapter.addDatas(list);
            }
        } else {
            if (list != null && !list.isEmpty()) {
                binding.empty.setVisibility(View.GONE);
                binding.noticeList.setVisibility(View.VISIBLE);
                adapter.setDatas(list);
            } else {
                adapter.setDatas(new ArrayList<>());
                binding.noticeList.setVisibility(View.GONE);
                binding.empty.setVisibility(View.VISIBLE);
            }
        }
        adapter.notifyDataSetChanged();
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEvent(MaterialEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_APPBAR_STATE_EXPANDED) {
            if (layoutParams != null) {
                layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                binding.llContainer.setLayoutParams(layoutParams);
                isParentAppBarCollapsed = false;
            }
        } else if (event.getMessageTag() == EventConstant.EVENT_APPBAR_STATE_COLLAPSED) {
            if (layoutParams != null) {
//                layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
//                binding.llContainer.setLayoutParams(layoutParams);
                isParentAppBarCollapsed = true;
            }
        } else if (event.getMessageTag() == EventConstant.EVENT_APPBAR_STATE_COMMON) {
            if (layoutParams != null) {
                layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
                binding.llContainer.setLayoutParams(layoutParams);
                isParentAppBarCollapsed = false;
            }
        }
    }

    public void updateData(String searchName) {
        if (pickNoticeModel != null) {
            isMore = false;
            //招标中
            pickNoticeModel.prepage.set(1);
            pickNoticeModel.getBiddingListData(searchName, typeNos, goodsType, tenderTypeNos, tenderApplyNo, time, price, areacode, citysNos, sortType, comNo);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
